{template 'public/header'}
{template 'public/comhead'}
<link rel="stylesheet" type="text/css" href="../addons/zh_tcwq/template/public/ygcsslist.css">
<style type="text/css">
    .ygmartop{margin-top: 30px;font-size: 12px;}
    .ygmartop2{margin-bottom: 10px;}
    .yg5_key>div{float: left;line-height: 34px;}
    .store_td1{height: 45px; width:50px;}


    .store_list_img{width: 40px;height: 40px;}
    .yg5_tabel{border-color: #e5e5e5;outline: 1px solid #e5e5e5;}
    .yg5_tr2>td{padding: 10px;border: 1px solid #e5e5e5;text-align: center;}
    .yg5_tr1>td{
        border: 1px solid #e5e5e5;
        padding-left: 15px;
        background-color: #FAFAFA;
        font-weight: bold;
        text-align: center;
    }
    .yg_name{width: 30%;height: 34px;line-height: 34px;color: #333;float: left;background-color: white;border: 1px solid #E4E4E4;text-align: center;}
    .yg5_btn{background-color: #EEEEEE;color: #333;border: 1px solid #E4E4E4;border-radius: 6px;width: 100px;height: 34px;}
    .jfbtn{background-color: #44ABF7;color: white;}
    .jfbtn:hover{background-color: #44ABF7;color: white;}
    .ygseledi{width: 60%;}
    .ygboxl{margin-bottom: 15px;}
    .yg_left{float: left;}
    .form-control{width: 70%;}

</style>
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>    
    <li  {if $type2=='all'} class="active" {/if}><a href="{php echo $this->createWebUrl('qggoodall',array('type'=>all));}">全部商品</a></li>
 <li   {if $type2=='wait'} class="active" {/if}><a href="{php echo $this->createWebUrl('qggoodall',array('type'=>wait,'is_tg'=>1));}">待审核</a></li>
 <li   {if $type2=='ok'} class="active" {/if}><a href="{php echo $this->createWebUrl('qggoodall',array('type'=>ok,'is_tg'=>2));}">已确认</a></li>
 <li   {if $type2=='no'} class="active" {/if}><a href="{php echo $this->createWebUrl('qggoodall',array('type'=>no,'is_tg'=>3));}">已拒绝</a></li>
</ul>
    <div class="row ygmartop">
        <form action="" method="get" class="col-md-12" style="padding: 0px;">
            <div class="col-md-12 ygboxl">
               <input type="hidden" name="c" value="site" />
               <input type="hidden" name="a" value="entry" />
               <input type="hidden" name="m" value="zh_tcwq" />
               <input type="hidden" name="do" value="qggoodall" />
                <div class="col-md-2" style="padding: 0px;">
                    <div class="yg_name">关键词</div>
                    <input type="text" name="keywords" value="{$_GPC['keywords']}" class="yg_left form-control" placeholder="请输入商品名称/商家名称"> 
                </div>
              
                <div class="col-md-3">
                    <div class="yg_name">
                        商品状态
                    </div>
                    <select class="ygseledi" style="color: #333;" name="is_shelves2">
                      <option value="">不限</option>
                      <option value="1" {if $_GPC['is_shelves2']==1}selected{/if}>已上架</option>
                      <option value="2" {if $_GPC['is_shelves2']==2}selected{/if}>已下架</option>
                    </select>                
                </div>
                <div class="col-md-3">
                    <div class="yg_name">
                        商品分类
                    </div>
                    <select class="ygseledi" style="color: #333;" name="type_id">
                    <option value="">不限</option>
                    {loop $type  $item2}
                      <option value="{$item2['id']}" {if $_GPC['type_id']==$item2['id']}selected{/if}>{$item2['name']}</option>
                      {/loop}
                    </select>                
                </div>
                <div class="col-md-1">
                    <input type="submit" value="搜索" name="submit" class="btn btn-primary btn-sm"/>
                    <input type="hidden" name="token" value="{$_W['token']}"/>
                </div>
            </div>
        </form>
  </div>
<div class="main">
<div class="panel panel-default">
        <div class="panel-body ygbtn">
        <div class="btn ygyouhui2" id="allsj">批量上架</div>
        <div class="btn ygshouqian2" id="allxj">批量下架</div>
        <div class="btn ygyouhui2" id="allxs">批量显示</div>
        <div class="btn ygshouqian2" id="allyc">批量隐藏</div>
        <div class="btn storegrey2" id="alldel">批量删除</div>
        </div>        
    </div>

    <!-- <div class="panel panel-default">
        <div class="panel-body">
            <a class="btn btn-primary" href="javascript:location.reload()"><i class="fa fa-refresh"></i>刷新</a>
        </div>
    </div> -->
    <!-- 门店列表部分开始 -->
        <div class="panel panel-default">
            <div class="panel-heading">
                商品列表
            </div>
            <div class="panel-body" style="padding: 0px 15px;">
                <div class="row">
                    <table class="yg5_tabel col-md-12">
                        <tr class="yg5_tr1">
                        <td class="store_td1 col-md-1" style="text-align: center;">
                          <input type="checkbox" class="allcheck" />
                          <span class="store_inp">全选</span>                      
                        </td>
                            <td class="col-md-1 store_td1">顺序</td>
                            <td class="col-md-1">商品图片</td>
                            <td class="col-md-1">商品名称</td>
                            <td class="col-md-1">所属分类</td>
                            <td class="col-md-1">所属商家/所属城市</td>
                            <td class="col-md-1">开始时间</td>
                            <td class="col-md-1">总数量</td>
                            <td class="col-md-1">剩余数量</td>
                            <td class="col-md-1">售价</td>
                            <td class="col-md-1">发布时间</td>
                            <td class="col-md-1">抢购状态</td>
                            <td class="col-md-1">平台显示</td>
                            <td class="col-md-1">状态</td>
                            <td class="col-md-1">审核</td>
                            <td class="col-md-1">操作</td>
                        </tr>
                        {loop $list $row}
                        <tr class="yg5_tr2">
                        <td>
                          <input type="checkbox" name="test" value="{$row['id']}">
                        </td>
                            <td><div>{$row['num']}</div></td>
                            <td>
                                <img class="store_list_img" src="{media $row['logo']}" alt=""/>                                
                            </td>
                            {php $time=strtotime($row['end_time']); $time2=time(); $time3=strtotime($row['start_time']);}
                            <td>{$row['name']}</td>
                            <td>{$row['type_name']}</td>
                            <td>{$row['store_name']}{if $row['cityname']}({$row['cityname']}){else}（全国版）{/if}</td>
                            <td>{$row['start_time']}</td>
                            
                            <td>{$row['number']}</td>
                            <td>{$row['surplus']}</td>
                            <td>{$row['money']}</td>
                            <td>{$row['time']}</td>
                             <td>{if $time<$time2}<span class="label storegrey">已结束</span>{else}<span class="label storeblue">抢购中</span>{/if}</td>
                             <td>{if $row['state2']==1}<a href="{php echo $this->createWebUrl('qggoodall', array('id' => $row['id'],'state2'=>2))}"><span class="label storeblue">显示</span></a>{else}<a href="{php echo $this->createWebUrl('qggoodall', array('id' => $row['id'],'state2'=>1))}"><span class="label storered">隐藏</span></a>{/if}</td>
                            <td>{if $row['state']==1}<a href="{php echo $this->createWebUrl('qggoodall', array('id' => $row['id'],'state'=>2))}"><span class="label storeblue">上架</span></a>{else}<a href="{php echo $this->createWebUrl('qggoodall', array('id' => $row['id'],'state'=>1))}"><span class="label storered">下架</span></a>{/if}</td>
                              <td>{if $row['is_tg']==1}
                              <a href="{php echo $this->createWebUrl('qggoodall', array('id' => $row['id'],'sh'=>2))}"><span class="label storeblue">通过</span></a>
                              <a href="{php echo $this->createWebUrl('qggoodall', array('id' => $row['id'],'sh'=>3))}"><span class="label storered">拒绝</span></a>
                              {elseif $row['is_tg']==2}
                                <span class="label storeblue">已通过</span>
                            {elseif $row['is_tg']==3}
                                <span class="label storegrey">已拒绝</span>
                              {/if}
                              </td>

                            <td>
                                <a href="{php echo $this->createWebUrl('addqggoodall', array('id' => $row['id']))}" class="storespan btn btn-xs">
                                    <span class="fa fa-pencil"></span>
                                    <span class="bianji">编辑
                                        <span class="arrowdown"></span>
                                    </span>
                                
                                </a>
                                <a href="javascript:void(0);" class="storespan btn btn-xs" data-toggle="modal" data-target="#myModal{$row['id']}">
                                    <span class="fa fa-trash-o"></span>
                                    <span class="bianji">删除
                                        <span class="arrowdown"></span>
                                    </span>
                                </a>
                            </td>
                        </tr>
                    <div class="modal fade" id="myModal{$row['id']}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                      <div class="modal-dialog" role="document">
                        <div class="modal-content">
                          <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">提示</h4>
                        </div>
                        <div class="modal-body" style="font-size: 20px">
                            确定删除么？
                        </div>
                        <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <a href="{php echo $this->createWebUrl('qggoodall', array('op'=>'del','id' => $row['id']))}" type="button" class="btn btn-info" >确定</a>
                        </div>
                    </div>
                </div>
            </div>
                        {/loop}
                   {if empty($list)}
                        <tr class="yg5_tr2">
                            <td colspan="15">
                              暂无商品信息
                            </td>
                        </tr>         
                    {/if}
                    </table>
                </div>
            </div>
        </div>
   
</div>
<div class="text-right we7-margin-top">{$pager}</div>
<script type="text/javascript">
    $(function(){
        $("#frame-23").show();
        $("#yframe-23").addClass("wyactive");
        $(".allcheck").on('click',function(){
            var checked = $(this).get(0).checked;
            $("input[type=checkbox]").prop("checked",checked);
        });

         // ———————————————批量拒绝———————————————
        $("#alldel").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要删除的商品!');
                return false;
            }else if(confirm("确认要删除此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });
                console.log(id)
                $.ajax({
                    type:"post",
                    url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=Delqggoods&m=zh_tcwq",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);      
                       location.reload();
                    }
                })               
            }
        });
         // ———————————————批量上架———————————————
        $("#allsj").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要上架的商品!');
                return false;
            }else if(confirm("确认要上架此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });
                console.log(id)
                $.ajax({
                    type:"post",
                    url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=qggoodsSj&m=zh_tcwq",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);      
                       location.reload();
                    }
                })               
            }
        });
        // ———————————————批量下架———————————————
        $("#allxj").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要下架的商品!');
                return false;
            }else if(confirm("确认要下架此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });
                console.log(id)
                $.ajax({
                    type:"post",
                    url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=qggoodsXj&m=zh_tcwq",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);      
                       location.reload();
                    }
                })               
            }
        });



           // ———————————————批量显示———————————————
        $("#allxs").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要显示的商品!');
                return false;
            }else if(confirm("确认要显示此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });
                console.log(id)
                $.ajax({
                    type:"post",
                    url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=qggoodsxs&m=zh_tcwq",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);      
                       location.reload();
                    }
                })               
            }
        });
        // ———————————————批量隐藏———————————————
        $("#allyc").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要隐藏的商品!');
                return false;
            }else if(confirm("确认要隐藏此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });
                console.log(id)
                $.ajax({
                    type:"post",
                    url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=qggoodsyc&m=zh_tcwq",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);      
                       location.reload();
                    }
                })               
            }
        });



    })
</script>